<?php
/**
 * Created by PhpStorm.
 * User: kang
 * Date: 16/2/25
 * Time: 10:56
 */
class Model_User extends Model_Base
{
    /**
     * @param $param['passwd']  32位md5密码
     * @param $param['username']  用户名
     */
    public function getUser($param)
    {
        try {
            $user = DB::select ("uid","name","role","forbid")->from ( 'user' )->where ( 'name' , '=' , $param[ 'username' ] )->and_where ( 'passwd' , '=' , $param[ 'passwd' ] )->execute ()->current ();
            return $user;
        }catch(Exception $e){
            Log::instance()->add(Log::ERROR,$e->getMessage());
            return false;
        }
    }

    public function getUserByRole($role)
    {
        try{
            $user = DB::select('uid','name','role','forbid')->from('user')->where('role','=',$role)->execute()->as_array();
            return $user;
        }catch(Exception $e){
            Log::instance()->add(Log::ERROR,$e->getMessage());
            return false;
        }
    }



}

